package com.xjc.business.controller.sysadmin;

import com.xjc.business.entity.vo.PageVo;
import com.xjc.business.entity.vo.sysadmin.PersonVo;
import com.xjc.business.service.SchoolAdminsService;
import com.xjc.system.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 徐锦程
 * 时间:2025-01-26 15:52
 */
@RestController
@RequestMapping("/sys_admin/person")
public class SysPersonController {

    @Autowired
    SchoolAdminsService schoolAdminsService;

    /**
     * 分页查询学校管理员
     * @param pageSize 每页条数
     * @param currentPage 当前页码
     * @param username 用户名
     * @param nickname 昵称
     * @param status 状态
     * @return 数据
     */
    @GetMapping("/page/{pageSize}/{currentPage}")
    public Result<PageVo<PersonVo>> getPersonPage(
            @PathVariable(value = "pageSize", required = false) Integer pageSize,
            @PathVariable(value = "currentPage",required = false) Integer currentPage,
            String username,
            String nickname,
            Integer status
            ){
        if(pageSize == null || pageSize <= 0){
            pageSize = 10;
        }
        if(currentPage == null || currentPage <= 0){
            currentPage = 1;
        }

        return schoolAdminsService.getPersonPage(pageSize, currentPage, username, nickname, status);
    }
}
